/**
 * Created with IntelliJ IDEA.
 * Description:链表中环的入口节点
 * User: wangxin
 * Date: 2024-10-21
 * Time: 22:37
 */
import java.util.*;

 class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}

public class test {
    public ListNode EntryNodeOfLoop(ListNode pHead) {
        if(pHead == null){
            return null;
        }
        ListNode slow = pHead;
        ArrayList<Integer> list = new ArrayList<>();
        while(slow != null){
            if(list.contains(slow.val)){
                return slow;
            }
            list.add(slow.val);
            slow = slow.next;

        }

        return null;
    }
}
